package com.yb0os1.ComplexJDKProxy.test;

import java.lang.reflect.Proxy;

public class ProxyFactory {
    public static Object getProxy(Object target) {
        return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(),
                (proxy, method, args) -> {
                    System.out.println("开始执行");
                    Object invoke = method.invoke(target, args);
                    System.out.println("执行结束");
                    return invoke;
                }
        );
    }
}
